﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using LibHuman;
namespace Human
{
	/// <summary>
	/// Summary description for frmInLyLichTrichNgang.
	/// </summary>
	public class frmInLyLichTrichNgang : System.Windows.Forms.Form
	{
        AccessData mDB = new AccessData();
        Language lan = new Language();
		private DataSet ds =new DataSet();
        string m_user="",s_mmyy="",s_bophan="",user_dn=""; 
		private bool bClear=true;			
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.CheckBox ckbToanCongTy;
		private System.Windows.Forms.Button butXem;
		private System.Windows.Forms.TextBox txbHoTenNV;
		private System.Windows.Forms.ComboBox cbobBoPhan;
		private System.Windows.Forms.Button butIn;
		private System.Windows.Forms.Button butThoat;
		public System.Windows.Forms.DataGrid dgrXemLyLich;
        private Button btnexel;
        private ComboBox cbo_hoten;
		private System.ComponentModel.Container components = null;

		public frmInLyLichTrichNgang(string s_makp,string s_userdn)
		{
			InitializeComponent();
            lan.Read_Language_to_Xml(this.Name.ToString(), this);
            lan.Changelanguage_to_English(this.Name.ToString(), this);
            s_bophan = s_makp;
            user_dn = s_userdn;
		}
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmInLyLichTrichNgang));
            this.ckbToanCongTy = new System.Windows.Forms.CheckBox();
            this.txbHoTenNV = new System.Windows.Forms.TextBox();
            this.cbobBoPhan = new System.Windows.Forms.ComboBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.dgrXemLyLich = new System.Windows.Forms.DataGrid();
            this.butThoat = new System.Windows.Forms.Button();
            this.butIn = new System.Windows.Forms.Button();
            this.butXem = new System.Windows.Forms.Button();
            this.btnexel = new System.Windows.Forms.Button();
            this.cbo_hoten = new System.Windows.Forms.ComboBox();
            ((System.ComponentModel.ISupportInitialize)(this.dgrXemLyLich)).BeginInit();
            this.SuspendLayout();
            // 
            // ckbToanCongTy
            // 
            this.ckbToanCongTy.ForeColor = System.Drawing.Color.Blue;
            this.ckbToanCongTy.Location = new System.Drawing.Point(64, 8);
            this.ckbToanCongTy.Name = "ckbToanCongTy";
            this.ckbToanCongTy.Size = new System.Drawing.Size(91, 24);
            this.ckbToanCongTy.TabIndex = 0;
            this.ckbToanCongTy.Text = "Toàn đơn vị";
            this.ckbToanCongTy.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.ckbToanCongTy.CheckedChanged += new System.EventHandler(this.ckbToanCongTy_CheckedChanged);
            this.ckbToanCongTy.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ckbToanCongTy_KeyDown);
            // 
            // txbHoTenNV
            // 
            this.txbHoTenNV.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txbHoTenNV.Location = new System.Drawing.Point(174, 8);
            this.txbHoTenNV.Name = "txbHoTenNV";
            this.txbHoTenNV.Size = new System.Drawing.Size(83, 22);
            this.txbHoTenNV.TabIndex = 2;
            this.txbHoTenNV.Visible = false;
            this.txbHoTenNV.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txbHoTenNV_KeyDown);
            // 
            // cbobBoPhan
            // 
            this.cbobBoPhan.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cbobBoPhan.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cbobBoPhan.Location = new System.Drawing.Point(64, 48);
            this.cbobBoPhan.Name = "cbobBoPhan";
            this.cbobBoPhan.Size = new System.Drawing.Size(193, 24);
            this.cbobBoPhan.TabIndex = 1;
            this.cbobBoPhan.SelectedIndexChanged += new System.EventHandler(this.cbobBoPhan_SelectedIndexChanged);
            this.cbobBoPhan.SelectedValueChanged += new System.EventHandler(this.cbobBoPhan_SelectedValueChanged);
            this.cbobBoPhan.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbobBoPhan_KeyDown);
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(8, 54);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(53, 13);
            this.label1.TabIndex = 10;
            this.label1.Text = "Bộ phận :";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label2
            // 
            this.label2.Location = new System.Drawing.Point(16, 84);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(45, 13);
            this.label2.TabIndex = 11;
            this.label2.Text = "Họ tên :";
            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // dgrXemLyLich
            // 
            this.dgrXemLyLich.AlternatingBackColor = System.Drawing.Color.LightGray;
            this.dgrXemLyLich.BackColor = System.Drawing.Color.Gainsboro;
            this.dgrXemLyLich.BackgroundColor = System.Drawing.Color.Silver;
            this.dgrXemLyLich.CaptionBackColor = System.Drawing.Color.LightSteelBlue;
            this.dgrXemLyLich.CaptionFont = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dgrXemLyLich.CaptionForeColor = System.Drawing.Color.MidnightBlue;
            this.dgrXemLyLich.CaptionText = "Thông Tin Nhân Viên";
            this.dgrXemLyLich.DataMember = "";
            this.dgrXemLyLich.HeaderForeColor = System.Drawing.SystemColors.ControlText;
            this.dgrXemLyLich.Location = new System.Drawing.Point(16, 176);
            this.dgrXemLyLich.Name = "dgrXemLyLich";
            this.dgrXemLyLich.Size = new System.Drawing.Size(288, 136);
            this.dgrXemLyLich.TabIndex = 11;
            this.dgrXemLyLich.CurrentCellChanged += new System.EventHandler(this.dgrXemLyLich_CurrentCellChanged);
            this.dgrXemLyLich.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dgrXemLyLich_KeyDown);
            // 
            // butThoat
            // 
            this.butThoat.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.butThoat.Image = global::Human.Properties.Resources.close_r;
            this.butThoat.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butThoat.Location = new System.Drawing.Point(209, 119);
            this.butThoat.Name = "butThoat";
            this.butThoat.Size = new System.Drawing.Size(60, 28);
            this.butThoat.TabIndex = 4;
            this.butThoat.Text = "Thoát";
            this.butThoat.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.butThoat.Click += new System.EventHandler(this.butThoat_Click);
            // 
            // butIn
            // 
            this.butIn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.butIn.Image = global::Human.Properties.Resources.t_printer;
            this.butIn.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butIn.Location = new System.Drawing.Point(77, 119);
            this.butIn.Name = "butIn";
            this.butIn.Size = new System.Drawing.Size(60, 28);
            this.butIn.TabIndex = 5;
            this.butIn.Text = "In";
            this.butIn.Click += new System.EventHandler(this.butIn_Click);
            // 
            // butXem
            // 
            this.butXem.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.butXem.Image = global::Human.Properties.Resources.t_search;
            this.butXem.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butXem.Location = new System.Drawing.Point(11, 119);
            this.butXem.Name = "butXem";
            this.butXem.Size = new System.Drawing.Size(60, 28);
            this.butXem.TabIndex = 3;
            this.butXem.Text = "  Xem";
            this.butXem.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.butXem.Click += new System.EventHandler(this.butXem_Click);
            // 
            // btnexel
            // 
            this.btnexel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnexel.Image = global::Human.Properties.Resources.white_excel;
            this.btnexel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btnexel.Location = new System.Drawing.Point(143, 119);
            this.btnexel.Name = "btnexel";
            this.btnexel.Size = new System.Drawing.Size(60, 28);
            this.btnexel.TabIndex = 6;
            this.btnexel.Text = "Excel";
            this.btnexel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.btnexel.Click += new System.EventHandler(this.btnexel_Click);
            // 
            // cbo_hoten
            // 
            this.cbo_hoten.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cbo_hoten.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cbo_hoten.Location = new System.Drawing.Point(64, 79);
            this.cbo_hoten.Name = "cbo_hoten";
            this.cbo_hoten.Size = new System.Drawing.Size(193, 24);
            this.cbo_hoten.TabIndex = 2;
            this.cbo_hoten.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbo_hoten_KeyDown);
            // 
            // frmInLyLichTrichNgang
            // 
            this.ClientSize = new System.Drawing.Size(280, 165);
            this.Controls.Add(this.btnexel);
            this.Controls.Add(this.dgrXemLyLich);
            this.Controls.Add(this.butThoat);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.butIn);
            this.Controls.Add(this.cbo_hoten);
            this.Controls.Add(this.cbobBoPhan);
            this.Controls.Add(this.txbHoTenNV);
            this.Controls.Add(this.butXem);
            this.Controls.Add(this.ckbToanCongTy);
            this.ForeColor = System.Drawing.Color.DarkBlue;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "frmInLyLichTrichNgang";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "In lý lịch trích ngang";
            this.Load += new System.EventHandler(this.frmInLyLichTrichNgang_Load);
            this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.frmInLyLichTrichNgang_MouseMove);
            ((System.ComponentModel.ISupportInitialize)(this.dgrXemLyLich)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		private void ckbToanCongTy_CheckedChanged(object sender, System.EventArgs e)
		{
			cbobBoPhan.Enabled = !ckbToanCongTy.Checked;
			cbo_hoten.Enabled = !ckbToanCongTy.Checked;
            cbo_hoten.Text = "";
			cbobBoPhan.Text="";
			cbobBoPhan.SelectedIndex=-1;
            cbo_hoten.SelectedIndex = -1;
		}

		private void butThoat_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
		private void Load_BoPhan()
		{
			try
			{
				cbobBoPhan.DisplayMember="tenbp";
				cbobBoPhan.ValueMember="madv";
				cbobBoPhan.DataSource=mDB.get_bophan().Tables[0];
			}
			catch{}
		}
		private void frmInLyLichTrichNgang_Load(object sender, System.EventArgs e)
		{
            m_user = mDB.user;
            cbobBoPhan.Focus();
			Load_BoPhan();
			cbobBoPhan.SelectedIndex=-1;
            cbo_hoten.SelectedIndex = -1;
		}
		private void butXem_Click(object sender, System.EventArgs e)
		{
			if(ckbToanCongTy.Checked==false && cbobBoPhan.SelectedIndex==-1 && txbHoTenNV.Text=="")
			{
				MessageBox.Show(lan.Change_language_MessageText("Chưa chọn đối tượng cần xem"),lan.Change_language_MessageText("Thông báo"));
			}
			else
				print(1);
		}
		private void butIn_Click(object sender, System.EventArgs e)
		{
			if(ckbToanCongTy.Checked==false && cbobBoPhan.SelectedIndex==-1 && txbHoTenNV.Text=="")
			{
				MessageBox.Show(lan.Change_language_MessageText("Chưa chọn đối tượng cần in"),lan.Change_language_MessageText("Thông báo"));
			}
			else
                print(1);
		}

		private void ckbToanCongTy_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode.ToString() == "Enter")
				SendKeys.Send("{Tab}");		
		}

		private void cbobBoPhan_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter)
				SendKeys.Send("{Tab}{F4}");
		}

		private void txbHoTenNV_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode.ToString() == "Enter")
			{
				SendKeys.Send("{Tab}");				
				this.Size=new Size(328,352);
				dgrXemLyLich.Focus();
				cbobBoPhan.Enabled=!txbHoTenNV.Enabled;
				ckbToanCongTy.Enabled=!txbHoTenNV.Enabled;
			}
		}

		private void dgrXemLyLich_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode.ToString() == "Enter")
				SendKeys.Send("{Tab}{F4}");
		}		

		private void frmInLyLichTrichNgang_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if (bClear)
			{
				cbobBoPhan.SelectedIndex=-1;
				bClear=false;
			}
		}

		private void dgrXemLyLich_CurrentCellChanged(object sender, System.EventArgs e)
		{
			string ma_nvl,ho_nv;
			int i=dgrXemLyLich.CurrentCell.RowNumber;							
			ma_nvl= dgrXemLyLich[i,2].ToString().Trim();	
			ho_nv=dgrXemLyLich[i,1].ToString().Trim();			
			txbHoTenNV.Text=ma_nvl;
		}
		private void print(int prn)
		{
			try
			{				
                DataSet dstmp = new DataSet();
                ExportToExcel exp = new ExportToExcel();
                string ngayht = DateTime.Now.ToString("yyyy-MM-dd", null);
                s_mmyy = ngayht.Trim().Substring(5, 2) + ngayht.Trim().Substring(2, 2);
                string sql = "";
                sql = " select bp.madv,bp.tenbp,ll.manv,trim(ll.ho)||' '||trim(ll.ten) as hoten,";
                sql += " case when ll.phai='Nam' then ll.namsinh else '' end as nsNam,case when ll.phai='Nam' then '' else ll.namsinh end as nsNu, ";
                sql += " ll.quequan as quequan,ll.diachi||', '||trim(g.tenquan)||', '||trim(f.tentt) as truquan,";
                sql += " dt.tendt as dantoc,hv.tenhv as hocvan,";
                sql += " to_char(ll.ngay_t_gia,'dd/mm/yyyy') as ngay_t_gia,";
                sql += " to_char(ll.ngay_doan,'dd/mm/yyyy') as ngay_doan,";
                sql += " to_char(ll.cthuc_dang,'dd/mm/yyyy') as cthuc_dang ,";
                sql += " cv.diengiai as chucvu,bc.tenbang as bangcap,to_char(hd.ngaydenct,'dd/mm/yyyy') as Ngaydentct,";
                sql += " cha.htendtg as tenCha,cha.namsinh as nsCha,cha.ghichu as noioCha,me.htendtg as tenMe,me.namsinh as nsMe,me.ghichu as noioMe,"; //cha.nsCha,cha.noioChame.nsMe,me.noioMe
                sql += " vc.htendtg as tenVc,vc.namsinh as nsVc,vc.quequan as noioVc";			//vc.nsVc,vc.noioVc,vc.ghichu

                sql += " from " + m_user + ".llnv as ll inner join  " + m_user + ".hopdong as hd on ll.manv=hd.manv";
                sql += " inner join  " + m_user + ".bophan as bp on ll.madv=bp.madv";
                sql += " left join " + m_user + ".hocvan hv on ll.mahv=hv.mahv";                
                sql += " left join " + m_user + ".dmcv cv on cv.macv=hd.macv";
                sql += " inner join  " + m_user + ".btdtt f on f.matt=ll.t_diachi";
                sql += " inner join " + m_user + ".btdquan g on g.maqu=ll.h_diachi";
                sql += " left join " + m_user + ".dantoc dt on dt.madt=ll.madt";
                sql += " left join " + m_user + ".bangcap bc on bc.mabangcap=ll.td_nnghiep";
                sql += " left join " + m_user + ".gcanh_cha as cha on ll.manv=cha.manv";
                sql += " left join " + m_user + ".gcanh_me as me on ll.manv=me.manv";
                sql += " left join " + m_user + ".gcanh_vochong as vc on ll.manv=vc.manv";
                sql += " inner join " + m_user + ".max_lan ml on hd.manv=ml.manv";
                sql += " where hd.ngaynghi is null ";                
                if (ckbToanCongTy.Checked)
                    sql += "";
                else 
                    if (cbobBoPhan.SelectedIndex != -1)
                    {
                        sql += " and ll.madv='" + cbobBoPhan.SelectedValue.ToString() + "'";
                        if (cbo_hoten.SelectedIndex!=-1)
                            sql += " and trim(ll.ho)||' '||trim(ll.ten)='" + cbo_hoten.Text.ToString().Trim().ToUpper() + "'";
                    }
                sql += " and hd.lan=ml.lan";
                sql += " and (hd.ngaynghi is null or to_timestamp(hd.ngaynghi,'yyyy-mm-dd') > to_timestamp('" + ngayht + "','yyyy-mm-dd'))";
                sql += " order by bp.sothutu asc,cv.stt,ll.manv";                
				ds=mDB.get_data(sql);
                ds.WriteXml("..\\xml\\h_lylichtrichngang.xml", XmlWriteMode.WriteSchema);
				if (ds.Tables[0].Rows.Count>0)
				{

                    switch (prn)
                    {
                        case 1: frmReport f = new frmReport(mDB, ds,lan.Change_language_MessageText("LÝ LỊCH TRÍCH NGANG ĐẾN ")+ " 01/" + DateTime.Now.Month.ToString().PadLeft(2, '0') + "/" + DateTime.Now.Year.ToString().PadLeft(4, '0'), "h_lylichtrichngang.rpt", true, user_dn);//danhsach_trichngang1.rpt
                            f.ShowDialog(this);
                            break;
                        case 2: dstmp = xuat_exel(ds);
                            exp.exel_lylichtnnv(dstmp, "lylichtrichngang",s_mmyy);
                            break;
                    }                   
                        
						ckbToanCongTy.Enabled=true;
						cbobBoPhan.Enabled=true;
						txbHoTenNV.Enabled=true;
						ckbToanCongTy.Checked=false;
						cbobBoPhan.Text="";
						txbHoTenNV.Text="";
						this.Size=new Size(328,192);
					
				}
				else 
				{
					MessageBox.Show(lan.Change_language_MessageText("Chưa có đầy đủ dữ liệu"),lan.Change_language_MessageText("Thông Báo"));
					ckbToanCongTy.Enabled=true;
					cbobBoPhan.Enabled=true;
					txbHoTenNV.Enabled=true;
					ckbToanCongTy.Checked=false;
					cbobBoPhan.Text="";
					txbHoTenNV.Text="";
					this.Size=new Size(328,192);
				}
			}
			catch{}
		}
        private DataSet xuat_exel(DataSet dse)
        {
            string[] str = new string[] { "STT", "Họ Tên", "Nam", "Nữ", "Quê Quán", "Nơi Ở", "Dân Tộc", "Văn Hoá", "Ngày TGCM", "Ngày Vào Đoàn", "Ngày vào Đảng", "Chức Vụ", "Chuyên Môn", "Tên Cha", "Năm Sinh", "Nơi Ở", "Nghề Nghiệp", "Tên Mẹ", "Năm Sinh", "Nơi Ở", "Nghề Nghiệp", "Tên Vợ", "Năm Sinh", "Nơi Ở", "Nghề Nghiệp" };
            DataSet dse1 = new DataSet();
            dse1.Tables.Add();
            dse1.Tables[0].Columns.Add("stt",typeof(string));
            dse1.Tables[0].Columns.Add("hoten",typeof(string));
            dse1.Tables[0].Columns.Add("nsNam",typeof(string));
            dse1.Tables[0].Columns.Add("nsNu",typeof(string));
            dse1.Tables[0].Columns.Add("quequan",typeof(string));
            dse1.Tables[0].Columns.Add("truquan",typeof(string));
            dse1.Tables[0].Columns.Add("dantoc",typeof(string));
            dse1.Tables[0].Columns.Add("hocvan",typeof(string));
            dse1.Tables[0].Columns.Add("ngay_t_gia",typeof(string));
            dse1.Tables[0].Columns.Add("ngay_doan",typeof(string));
            dse1.Tables[0].Columns.Add("cthuc_dang",typeof(string));
            dse1.Tables[0].Columns.Add("chucvu",typeof(string));
            dse1.Tables[0].Columns.Add("bangcap",typeof(string));
            dse1.Tables[0].Columns.Add("tenCha",typeof(string));
            dse1.Tables[0].Columns.Add("nsCha", typeof(string));
            dse1.Tables[0].Columns.Add("noioCha", typeof(string));          
            dse1.Tables[0].Columns.Add("tenMe", typeof(string));
            dse1.Tables[0].Columns.Add("nsMe", typeof(string));
            dse1.Tables[0].Columns.Add("noioMe", typeof(string));           
            dse1.Tables[0].Columns.Add("tenVc", typeof(string));
            dse1.Tables[0].Columns.Add("nsVc", typeof(string));
            dse1.Tables[0].Columns.Add("noioVc", typeof(string));            

            DataRow nrow;
            int stt=0;
            foreach (DataRow r in dse.Tables[0].Rows)
            {
                stt++;
                nrow = dse1.Tables[0].NewRow();
                nrow["stt"] = stt.ToString();
                nrow["hoten"] = r["hoten"].ToString();
                nrow["nsNam"] = r["nsNam"].ToString();
                nrow["nsNu"] = r["nsNu"].ToString();
                nrow["quequan"] = r["quequan"].ToString();
                nrow["truquan"] = r["truquan"].ToString();
                nrow["dantoc"] = r["dantoc"].ToString();
                nrow["hocvan"] = r["hocvan"].ToString();
                nrow["ngay_t_gia"] = r["ngay_t_gia"].ToString();
                nrow["ngay_doan"] = r["ngay_doan"].ToString();
                nrow["cthuc_dang"] = r["cthuc_dang"].ToString();
                nrow["bangcap"] = r["bangcap"].ToString();
                nrow["tenCha"] = r["tenCha"].ToString();
                nrow["nsCha"] = r["nsCha"].ToString();               
                nrow["tenMe"] = r["tenMe"].ToString();
                nrow["nsMe"] = r["nsMe"].ToString();
                nrow["noioMe"] = r["noioMe"].ToString();               
                nrow["tenVc"] = r["tenVc"].ToString();
                nrow["nsVc"] = r["nsVc"].ToString();
                nrow["noioVc"] = r["noioVc"].ToString();               
                dse1.Tables[0].Rows.Add(nrow);
            }
            return dse1;
        }

        private void btnexel_Click(object sender, EventArgs e)
        {
            if (ckbToanCongTy.Checked == false && cbobBoPhan.SelectedIndex == -1 && txbHoTenNV.Text == "")
            {
                MessageBox.Show(lan.Change_language_MessageText("Chưa chọn đối tượng cần in"),lan.Change_language_MessageText("Thông báo"));
            }
            else
                print(2);
        }
        DataSet Ten_NV(string madv)
        {
            return mDB.get_data("SELECT manv,ho||' '||ten AS hoten" +
                " FROM " + mDB.user + ".llnv WHERE madv ='" + madv + "' order by manv");
        }
        private DataSet TenNV()
        {
            return mDB.get_data("SELECT manv,ho||' '||ten AS hoten from " + mDB.user + ".llnv order by manv");
        }
        private void load_hoten()
        {
            try
            {
                cbo_hoten.DisplayMember = "hoten";
                cbo_hoten.ValueMember = "manv";
                DataSet ds = new DataSet();
                if (cbobBoPhan.SelectedIndex != -1)
                    ds = Ten_NV(cbobBoPhan.SelectedValue.ToString().Trim());
                else
                    ds = TenNV();
                cbo_hoten.DataSource = ds.Tables[0];
                cbo_hoten.SelectedIndex = -1;           
            }
            catch { }
        }

        private void cbobBoPhan_SelectedValueChanged(object sender, EventArgs e)
        {
            if (cbobBoPhan.SelectedIndex != -1)
            {
                cbo_hoten.DataSource = null;
                cbobBoPhan.Update();
                load_hoten();
            }
        }

        private void cbo_hoten_KeyDown(object sender, KeyEventArgs e)
        {
            if (cbo_hoten.SelectedIndex != -1)
            {
                if (e.KeyCode == Keys.Enter)
                    butXem.Focus();
            }
        }

        private void cbobBoPhan_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

	}

}